<%@page import="org.hibernate.validator.constraints.SafeHtml.Tag" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <c:set var="ctx" value="${pageContext.request.contextPath}"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>法人基础变更申请页面</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <style type="text/css">
        .td {
            height: 30px;
            text-align: center;
            width: 18%;
        }

        .td div input, select {
            width: 66%;
            -moz-border-radius: 5px;
            -webkit-border-radius: 5px;
            -ms-border-radius: 5px;
            -khtml-border-radius: 5px;
            border-radius: 5px;
        }

    </style>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <div tabid="tabA" title="基本信息" lselected="true">
                <form id="formSet1">
                    <div class="fieldset1 tabel_col clearFix">
                        <div class="caption">
                            <span class="title">基本信息</span>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">客户类型</div>
                            <div class="field">
                                <span class="requiredSymbol">法人</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">企业名称</div>
                            <div class="field">
                                <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${cstNm }" validate="{required:true,maxlength:50}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">客户关系</div>
                            <div class="field test_combo">
                                <input name="cstRlTyp" id="cstRlTyp" type="text" ltype="combobox" placeholder="请选择" validate="{required:true}"></input>
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">证件类型</div>
                            <div class="field">
                                <select name="certTypCd" id="certTypCd" data-value="${certTypCd }" disabled="disabled">
                                    <c:forEach items="${searchSelectCertTypCdList }" var="kv" begin="0" step="1"
                                               varStatus="status">
                                        <c:if test="${status.index == 0}">
                                            <option value="${kv.key }" selected>${kv.value }</option>
                                        </c:if>
                                        <c:if test="${status.index != 0}">
                                            <option value="${kv.key }">${kv.value }</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">证件号码</div>
                            <div class="field">
                                <input name="certNo" id="certNo" type="text" class="ui-textbox" value="${certNo }" validate="{required:true,maxlength:30}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">营业执照注册号</div>
                            <div class="field">
                                <input name="bizLicNo" id="bizLicNo" type="text" class="ui-textbox" value="" validate="{required:true,maxlength:30}">
                                <span class="requiredSymbol" id="bizLicNoRequiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">中征码</div>
                            <div class="field">
                                <input name="loanCardCd" id="loanCardCd" type="text" class="ui-textbox" value="" disabled="disabled" validate="{required:true,maxlength:16,digits:true}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">法定代表人</div>
                            <div class="field">
                                <input name="lowerCstNm" id="lowerCstNm" type="text" class="ui-textbox" value="${lowerCstNm }" onChange="setFrTeamInfo()" validate="{required:true,nmcharacter:true,maxlength:50}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">证件类型</div>
                            <div class="field">
                                <select name="corpForCertTypCd" id="corpForCertTypCd" data-value="${corpForCertTypCd }" validate="{required:true, select: true}">
                                    <c:forEach items="${searchSelectCertTypCdForNpList }" var="kv" begin="0" step="1"
                                               varStatus="status">
                                        <c:if test="${status.index == 0}">
                                            <option value="${kv.key }" checked>${kv.value }</option>
                                        </c:if>
                                        <c:if test="${status.index != 0}">
                                            <option value="${kv.key }">${kv.value }</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33" style="display:none">
                            <div class="label">证件类型</div>
                            <div class="field">
                                <select name="tcorpForCertTypCd" id="tcorpForCertTypCd">
                                    <c:forEach items="${searchSetlectCertTypCdForNpList }" var="kv" begin="0" step="1"
                                               varStatus="status">
                                        <c:if test="${status.index == 0}">
                                            <option value="${kv.key }" checked>${kv.value }</option>
                                        </c:if>
                                        <c:if test="${status.index != 0}">
                                            <option value="${kv.key }">${kv.value }</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">代表人身份证号码</div>
                            <div class="field">
                                <input name="lowerCertNo" id="lowerCertNo" type="text" class="ui-textbox" value="${lowerCertNo }" onchange="setFrPassNo();frVerifyID()" validate="{required:true}">
                                <span class="requiredSymbol">*</span>
                                <span id="sFrVerifyID" class="addFrVerifyID" onclick="frVerifyID()" style="display:none">
		                        	<a href="javascript:;" id="addFrVerifyID" pass='n' class="liger_tip" title="未验证"><i class="sqIco sqIco_8"></i></a>
		                    	</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">企业简称</div>
                            <div class="field">
                                <input name="shtNm" id="shtNm" type="text" class="ui-textbox" value="" validate="{required:false,maxlength:50}">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">企业性质</div>
                            <div class="field">
                                <select name="corpTypCd" id="corpTypCd" data-value="">
                                    <c:forEach items="${searchSelectCorpTypCdList }" var="kv" begin="0" step="1"
                                               varStatus="status">
                                        <c:if test="${status.index == 0}">
                                            <option value="${kv.key }" checked>${kv.value }</option>
                                        </c:if>
                                        <c:if test="${status.index != 0}">
                                            <option value="${kv.key }">${kv.value }</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">注册资本金</div>
                            <div class="field" style="margin-right: 5px;">
                                <input name="regCapAmt" id="regCapAmt" type="text" class="ui-textbox" value="" ligerui="width: 110" validate="{required:true, digits:true, maxlength:20}">
                                <select name="regCapUntCd" id="regCapUntCd" ligerui="width: 60" data-value="">
                                    <c:forEach items="${searchSelectRegCapUntCdList }" var="kv" begin="0" step="1"
                                               varStatus="status">
                                        <c:if test="${status.index == 0}">
                                            <option value="${kv.key }" checked>${kv.value }</option>
                                        </c:if>
                                        <c:if test="${status.index != 0}">
                                            <option value="${kv.key }">${kv.value }</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">实收资本金</div>
                            <div class="field" style="margin-right: 5px;">
                                <input name="paidCapAmt" id="paidCapAmt" type="text" class="ui-textbox" value="" ligerui="width: 110" validate="{required:false, digits:true, maxlength:20}">
                                <select name="paidCapUntCd" id="paidCapUntCd" ligerui="width: 60" data-value="">
                                    <c:forEach items="${searchSelectPaidCapUntCdList }" var="kv" begin="0" step="1"
                                               varStatus="status">
                                        <c:if test="${status.index == 0}">
                                            <option value="${kv.key }" checked>${kv.value }</option>
                                        </c:if>
                                        <c:if test="${status.index != 0}">
                                            <option value="${kv.key }">${kv.value }</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">成立日期</div>
                            <div class="field">
                                <input name="regDt" id="regDt" type="text" class="ui-datepicker" value=""
                                       validate="{required:true}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">营业期限至</div>
                            <div class="field">
                                <input name="expDt" id="expDt" type="text" class="ui-datepicker" value=""
                                       validate="{required:true}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">税务登记证</div>
                            <div class="field">
                                <input name="taxRegNo" id="taxRegNo" type="text" class="ui-textbox" value=""
                                       validate="{required:true,numberAndMiddleLine:false,maxlength:20}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">企业传真</div>
                            <div class="field">
                                <input name="corpTax" id="corpTax" type="text" class="ui-textbox" value=""
                                       validate="{numberAndMiddleLine:true,maxlength:30}">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">注册电话</div>
                            <div class="field">
                                <input name="regTel" id="regTel" type="text" class="ui-textbox" value="" validate="{required:false, fixedPhone: true}">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">办公电话</div>
                            <div class="field">
                                <input name="officeTel" id="officeTel" type="text" class="ui-textbox" value="" validate="{required:true, fixedPhone: true}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">办公用房使用权面积</div>
                            <div class="field">
                                <input name="officeArea" id="officeArea" type="text" class="ui-textbox"
                                       ligerui="width: 110" value=""
                                       validate="{decimal:true, digits:true, maxlength:20}">
                                <span class="requiredSymbol">平方米</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">房产属性</div>
                            <div class="field">
                                <input name="prpAttr" id="prpAttr" type="text" class="ui-textbox" value=""
                                       validate="{maxlength:50}">
                            </div>
                        </div>
                        <div id="cstGuarDynamicBizdiv">
                            <%-- <jsp:include page="../cstdynamic/cstGuarDynamicPage.jsp"></jsp:include> --%>
                        </div>

                        <div id="cstGuar1DynamicBizdiv">
                            <%-- dynamic1  field --%>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">是否事业单位</div>
                            <div class="field">
                                <select name="isInst" id="isInst" data-value="" validate="{required:true}">
                                    <c:forEach items="${yNList }" var="kv" begin="0" step="1" varStatus="status">
                                        <c:if test="${status.index == 0}">
                                            <option value="${kv.key }" checked>${kv.value }</option>
                                        </c:if>
                                        <c:if test="${status.index != 0}">
                                            <option value="${kv.key }">${kv.value }</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">开户许可证核准号</div>
                            <div class="field">
                                <input name="perMitNo" id="perMitNo" type="text" class="ui-textbox" value="" validate="{maxlength:30}">
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">还款方式</div>
                            <div class="field">
                                <select name="payTypCd" id="payTypCd" data-value="" validate="{required:false, select: false}">
                                    <option value="">请选择</option>
                                    <c:forEach items="${payTyplist }" var="kv">
                                        <option value="${kv.key }">${kv.value }</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">所属行业</div>
                            <div class="field">
                                <input name="indCd" id="indCd" type="text" class="ui-textbox" value="" ltype="combobox" validate="{required:true, select: false}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">经济行业分类</div>
                            <div class="field">
                                <input name="stdIndCd" id="stdIndCd" type="text" class="ui-textbox" value="" ltype="combobox" validate="{required:true, maxlength:30}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>

                        <div class="fieldBox col_33">
                            <div class="label">立项控制</div>
                            <div class="field">
                                <select name="prjCtrlCd" id="prjCtrlCd" data-value="" validate="{required:false, select: false}">
                                    <option value="">请选择</option>
                                    <c:forEach items="${prjCtrlCdList }" var="kv">
                                        <option value="${kv.key }">${kv.value }</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">房产价值</div>
                            <div class="field">
                                <input name="prpVal" id="prpVal" type="text" class="ui-textbox" value="" validate="{required:false, maxlength:50}">
                            </div>
                        </div>
                        <ui:normalSelect pgCd="custCorpPage" cmpCd="custPageMainForm" cmpDtlCd="cstLvlCd" orgCds="${orgCds }"></ui:normalSelect>
                        <!-- 标准区域 -->
                        <jsp:include page="../../system/sysRegion/sysStdRegion.jsp" flush="true">
                            <jsp:param name="sysStdRegionDefShowLvl" value="3"/>
                            <jsp:param name="sysStdRegionProvCdNm" value="注册地行政区划-省份"/>
                            <jsp:param name="sysStdRegionCityCdNm" value="城市"/>
                            <jsp:param name="sysStdRegionDistCdNm" value="区\\县"/>
                        </jsp:include>
                        <div class="fieldBox col_33" style="display:none">
                            <div class="label">成员类型</div>
                            <div class="field">
                                <select name="mTypCd" id="mTypCd" data-value="" validate="{required:true, select: true}">
                                    <c:forEach items="${searchSelectMTypCdList }" var="kv" begin="0"
                                               step="1" varStatus="status">
                                        <c:if test="${kv.key != 1}">
                                            <c:if test="${status.index == 0}">
                                                <option value="${kv.key }" checked>${kv.value }</option>
                                            </c:if>
                                            <c:if test="${status.index != 0}">
                                                <option value="${kv.key }">${kv.value }</option>
                                            </c:if>
                                        </c:if>
                                    </c:forEach>
                                </select>
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="label">经营范围</div>
                            <div class="field">
                                <input name="bizScope" id="bizScope" type="text" class="ui-textbox" value="" validate="{maxlength:250}">
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="label">注册地址</div>
                            <div class="field">
                                <input name="regAddr" id="regAddr" type="text" class="ui-textbox" value="" validate="{required:true,maxlength:120}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="label">通讯地址</div>
                            <div class="field">
                                <input name="postAddr" id="postAddr" type="text" class="ui-textbox" value="" validate="{required:true,maxlength:120}" placeholder="请填写邮件接收地址，如未填写将默认注册地址为实际通讯地址">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="label">贷款事项约定</div>
                            <div class="field" style="width: 100%;">
                                <textarea name="loanAss" id="loanAss" rows="4" class="l-textarea" style="width:99%" validate="{maxlength:200}"></textarea>
                            </div>
                        </div>
                        <div class="fieldBox col_100">
                            <div class="label">备注</div>
                            <div class="field" style="width: 100%;">
                                <textarea name="cstRem" id="cstRem" rows="4" class="l-textarea" style="width:99%" validate="{maxlength:200}"></textarea>
                            </div>
                        </div>
                    </div>

                    <div class="sqPanel">
                        <div class="sqPanel_head inL">
                            <div class="btnsBox inLC">
	                            <c:if test="${isModify == '1' && !(_audStsCd == '13' || _audStsCd == '14') }">
	                                <span id="cst_corp_team_add_btn_id" class="sq-button sq-button-round">添加</span>
	                            </c:if>
                            </div>
                            <span>主要团队成员</span>
                        </div>
                        <div class="sqPanel_body">
                            <table style="BORDER-COLLAPSE: collapse;margin-bottom:20px" borderColor=#ECECEC height=40 cellPadding=1 width="100%" align=center border=1>
                                <thead>
	                                <tr style="background:#E7FEF4">
	                                    <td class="td">职务</td>
	                                    <td class="td">姓名</td>
	                                    <td class="td">证件类型</td>
	                                    <td class="td">证件号</td>
	                                    <td class="td">电话</td>
	                                    <td class="td">操作</td>
	                                </tr>
                                </thead>
                                <tbody id="rows">
                                <c:choose>
                                    <c:when test="${id != null}">
                                        <c:forEach items="${teamMenList}" var="item">
                                            <tr>
                                                <td style="display:none">
                                                    <input name="teamId" id="teamId" type="text" value="${item.id}">
                                                </td>
                                                <td class="td">
                                                    <div>
                                                        <c:choose>
                                                            <c:when test="${item.mTypCd == 1 || item.mTypCd == 7 || item.mTypCd == 10}">
                                                                <select name="mTypCd" id="mTypCd" disabled="disabled">
                                                                    <c:forEach items="${searchSelectMTypCdList }" var="kv">
                                                                        <c:if test="${kv.key == item.mTypCd}">
                                                                            <option value="${kv.key }">${kv.value }</option>
                                                                        </c:if>
                                                                    </c:forEach>
                                                                </select>
                                                            </c:when>
                                                            <c:otherwise>
                                                                <select name="mTypCd" id="mTypCd" <c:if test="${isModify == '0' }">disabled="disabled"</c:if> >
                                                                    <c:forEach items="${searchSelectMTypCdList }" var="kv">
                                                                        <c:choose>
                                                                            <c:when test="${kv.key == item.mTypCd}">
                                                                                <option value="${kv.key }" selected="selected">${kv.value }</option>
                                                                            </c:when>
                                                                            <c:otherwise>
                                                                                <option value="${kv.key }">${kv.value }</option>
                                                                            </c:otherwise>
                                                                        </c:choose>
                                                                    </c:forEach>
                                                                </select>
                                                            </c:otherwise>
                                                        </c:choose>
                                                    </div>
                                                </td>
                                                <td class="td">
                                                    <div>
                                                        <input name="teamNm" id="teamNm" type="text" value="${item.mNm}" <c:if test="${isModify == '0' }">readonly="readonly"</c:if> />
                                                    </div>
                                                </td>
                                                <td class="td">
                                                    <div>
                                                        <select name="tcorpForCertTypCd" id="tcorpForCertTypCd" <c:if test="${isModify == '0' }">disabled="disabled"</c:if> >
                                                            <c:forEach items="${searchSelectCertTypCdForNpList }" var="kv">
                                                                <c:choose>
                                                                    <c:when test="${kv.key == item.certTypCd}">
                                                                        <option value="${kv.key }" selected="selected">${kv.value }</option>
                                                                    </c:when>
                                                                    <c:otherwise>
                                                                        <option value="${kv.key }">${kv.value }</option>
                                                                    </c:otherwise>
                                                                </c:choose>
                                                            </c:forEach>
                                                        </select>
                                                    </div>
                                                </td>
                                                <td class="td">
                                                    <div>
                                                        <input name="teamCertNo" id="teamCertNo" type="text" value="${item.certNo}" <c:if test="${isModify == '0' }">readonly="readonly"</c:if> />
                                                    </div>
                                                </td>
                                                <td class="td">
                                                    <div>
                                                        <input name="teamMp1" id="teamMp1" type="text" value="${item.mp1}" <c:if test="${isModify == '0' }">readonly="readonly"</c:if> />
                                                    </div>
                                                </td>
                                                <td class="td" style="display:none;">
                                                    <c:if test="${item.mTypCd != 1 && item.mTypCd != 7 && item.mTypCd != 10}">
                                                        <div>
                                                        	<a class="sq-button-hasicon" style="cursor:pointer" onclick="deleteRow(this)"><i class="sqBtnIco_7"></i>删除</a>
														</div>
                                                    </c:if>
                                                </td>
                                            </tr>
                                        </c:forEach>
                                    </c:when>
                                </c:choose>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="fieldset1 tabel_col tabel_col_s clearFix">
                        <div class="fieldBox col_100" id="fileModify">
                            <div class="label">资料</div>
                            <div class="field">
                                <jsp:include page="../../system/sysUlFilesRec/sysUlFileRecListDetail.jsp" flush="true">
                                    <jsp:param name="pkId" value="${id }"/>
                                    <jsp:param name="tabNm" value="CST_BSC_INFO"/>
                                </jsp:include>
                            </div>
                        </div>
                        <div class="fieldBox col_100" style="display:none;">
                            <div class="label">资料上传</div>
                            <div class="field">
                                <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true">
                                    <jsp:param name="filePath" value="customer"/>
                                </jsp:include>
                            </div>
                        </div>
                    </div>
                    <div class="btnsBox">
                        <input name="cId" id="cId" type="text" style="display: none;" value="${id}"/>
                        <c:if test="${isModify == '1' }">
                        	<span id="saveBtn1" class="sq-button sq-button-round">保存</span>
                        </c:if>
                    </div>
                </form>
            </div>
            <div tabid="tabB" title="备案信息">
                <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
            </div>
            <div tabid="tabI" title="银行账号" id="tabIId" style="dis">
                <iframe frameborder="0" name="tabI" id="tabI" src=""></iframe>
            </div>
            <div tabid="tabH" title="项目列表">
                <iframe frameborder="0" name="tabH" id="tabH" src=""></iframe>
            </div>
            <div tabid="tabD" title="征信信息" id="tabDId" style="dis">
                <iframe frameborder="0" name="tabD" id="tabD" src=""></iframe>
            </div>
            <div tabid="tabE" title="财务报表">
                <iframe frameborder="0" name="tabE" id="tabE" src=""></iframe>
            </div>
            <div tabid="tabF" title="中间人">
                <iframe frameborder="0" name="tabF" id="tabF" src=""></iframe>
            </div>
            <div tabid="tabG" title="沟通记录" id="tabGId">
                <iframe frameborder="0" name="tabG" id="tabG" src=""></iframe>
            </div>
            <div tabid="tabK" title="风险标记" id="tabKId">
                <iframe frameborder="0" name="tabK" id="tabK" src=""></iframe>
            </div>
            <div tabid="tabP" title="担保项目列表" id="tabPId" style="dis">
                <iframe frameborder="0" name="tabP" id="tabP" src=""></iframe>
            </div>
			<div tabid="tabR" title="变更记录">
				<iframe frameborder="0" name="tabR" id="tabR" src=""></iframe>
			</div>
        </div>
    </div>
</div>

<script>
    var pageInApp = {
        flag: true
    }; // to 下一级子窗口 接口
    var pageInTab = null;
    var loadedTabs = [];
    var checkFlag = 0;
    var dataList = "";
    
    var isFlow = '${isFlow}'; //流程标识 1：是，0或者空：否
    var modId = '${modId}'; //变更主表ID（流程业务主键）
	var isModify = '${isModify}'; //是否可修改基本信息，1：是，0：否
	var _audStsCd = '${_audStsCd}'; //客户状态（13：已立项  14：有担保项目）
    var currentBuOrgCd = '${currentBuOrgCd}'; //发起人所属事业部代码
	
    $(function () {
        initCstRlCombox();
        initIndCdTree();//初始化所属行业Tree,要放在form实例化前执行
        initStdIndCdTree();//要放在form实例化前执行
        initForm();
        initData();//修改初始化数据
        initTab();
        changeItemStatus(true);//禁用非修改项
        initEvent();
        disabledField();
		
        //根据修改标识设置表单域可编辑否
        if('${isModify}' == '1'){//可修改
        	changeModStatus(false);
        }else{//不可修改
        	changeModStatus(true);
        }
    });

    //初始化行业分类树
    var stdIndCdTree;

    function initStdIndCdTree() {
        if ($("#stdIndCd").length <= 0) {
            return;
        }
        ;
        //默认不加载数据,只是初始化而已,这里的数据等所属行业加载完后Set数据到这里
        stdIndCdTree = $("#stdIndCd").ligerComboBox({
            selectBoxWidth: 240,
            selectBoxHeight: 150,
            treeLeafOnly: false, //限制只能选叶节点，父节点不能点击
            tree: {
                //url: '<%=path%>/customer/cstbscinfo/initStdIndCdTree.do',
                ajaxType: 'get',
                checkbox: false,
                parentIcon: "none",
                needCancel: false,
                childIcon: "none",
                onSuccess: function () {
                    stdIndCdInitPass = true;//初始化数据的时候可以赋值
                    /*
                    if(stdIndCd && stdIndCdInitPass == true){//这里和赋值方法里面都有一个赋值,因为在赋值操作和这个下拉框赋值操作是异步的,谁在前谁在后不好说,所以在两个地方根据indCdVal是否存在来赋值数据
                        var treeSelect=liger.get("stdIndCd");
                         if(treeSelect){
                            treeSelect.setValue(stdIndCd);
                         }
                    } */
                }, isDisabled: function (o, outlineLevel) {
                    if (outlineLevel < 2) return true;
                }
            }, onChangeValue: function (value) {
                //var _stdIndCd = liger.get("stdIndCd").getValue();
                //获取第一个字母,设置所属行业的根为这个字母的树
                //reloadIndCdTree(_stdIndCd.charAt(0));
            }
        });
    }

    //初始化所属行业Tree, 这个组件为动态组件, 要做存在判断
    var indCdTree;

    function initIndCdTree() {
        if ($("#indCd").length <= 0) {
            return;
        }
        ;
        //加载数据
        indCdTree = $("#indCd").ligerComboBox({
            selectBoxWidth: 240,
            selectBoxHeight: 150,
            treeLeafOnly: false, //限制只能选叶节点，父节点不能点击
            tree: {
                url: '<%=path%>/customer/cstbscinfo/initIndCdTree.do',
                ajaxType: 'get',
                checkbox: false,
                parentIcon: "none",
                childIcon: "none",
                onSuccess: function () {
                    if (indCdVal) {//这里和赋值方法里面都有一个赋值,因为在赋值操作和这个下拉框赋值操作是异步的,谁在前谁在后不好说,所以在两个地方根据indCdVal是否存在来赋值数据
                        var treeSelect = liger.get("indCd");
                        if (treeSelect) {
                            treeSelect.setValue(indCdVal);
                        }
                    }
                }
            }, onChangeValue: function (value) {
                //一但这里有变化就让其选择经济行业分类
                var _stdIndCd = liger.get("indCd").getValue();
                //通过这个值首字母去找到经济行业分类
                reloadStdIndCdTree(_stdIndCd.charAt(0));
            }
        });
    }

    //根据所属行业选择的数据重新加载经济行业分类数据
    function reloadStdIndCdTree(_pCode) {
        stdIndCdTree.clear();
        var _url = "<%=path%>/customer/cstbscinfo/initStdIndCdTree.do";
        AjaxUtils.ajaxGet(_url, {pCode: _pCode}, function (msg) {
            if (CollectionUtils.isArray(msg)) {
                if (CollectionUtils.isNotEmpty(msg)) {//赋值,否则说明没有返回的数据不处理所属行业的数据,所属行业默认为全部数据
                    //获取所属行业值,然后在setData后在setValue,这样是解决在初始化走这个事件的时候把数据冲掉,有这步(1)后就会在回显上
                    //var _indCd = liger.get("stdIndCd").getValue();//(1)
                    stdIndCdTree.treeManager.setData(msg);
                    //alert(stdIndCd);
                    if (stdIndCd) {//如果这个有值说明初始化已经把值给了变量,这里就可以使用了
                        stdIndCdTree.setValue(stdIndCd);//(1)
                        stdIndCd = null;
                    }
                    stdIndCdTree.clear();
                }
            }
        }, false);
    }

    //新增、修改
    var isHaveCstRlTypeDBR = false;

    function initEvent() {
        saveEvent();
        //certNoKeyUpEvent();
    }

    //初始化客户关系类型下拉框
    function initCstRlCombox() {
        var cstRlTypChange = false;//只为了在加载初始化的时候不加载onChangeValue 事件,带前端解决后即可删除
        var _cstRlTypJson = ${cstRlTypCdList};
        var cstRlTypLCB = $("#cstRlTyp").ligerComboBox({
            isShowCheckBox: true,
            isMultiSelect: true,
            data: _cstRlTypJson,
            valueField: 'key',
            textField: 'value',
            onChangeValue: function (value) {
                if (!cstRlTypChange) return;

                var _cstRlTypObj = liger.get("cstRlTyp");
                var _cstRlTypValues = _cstRlTypObj.getValue();
                //如果是担保人则加载
                if (_cstRlTypValues.indexOf(CustomerConstant.CST_RL_TYPE_DBR_CD) != -1 && isHaveCstRlTypeDBR == false) {
                    reloadCstRlTypDBR(CustomerConstant.CST_RL_TYPE_DBR_CD);
                    isHaveCstRlTypeDBR = true;
                } else if (_cstRlTypValues.indexOf(CustomerConstant.CST_RL_TYPE_DBR_CD) == -1 && isHaveCstRlTypeDBR == true) {
                    reloadCstRlTypDBR(-1);
                    isHaveCstRlTypeDBR = false;
                }
                //有担保人的时候部分字段必填项设置：营业执照注册号
                var formSet1 = liger.get("formSet1");
                if (formSet1) {
                    if (_cstRlTypValues.indexOf(CustomerConstant.CST_RL_TYPE_DBR_CD) != -1) {//只是担保人的时候
                        formSet1.setFieldValidate("bizLicNo", {required: false, maxlength: 30});
                        $("#bizLicNoRequiredSymbol").addClass("Hide");
                    } else {//不限制
                        formSet1.setFieldValidate("bizLicNo", {required: true, maxlength: 20});
                        $("#bizLicNoRequiredSymbol").removeClass("Hide");
                    }
                }
            }
        });
        cstRlTypChange = true;
        var _cId = $("#cId").val();
        if (!_cId) {
            var currentCstRlTypeForAdd = ${currentCstRlTypeForAdd};
            $("#cstRlTyp").ligerGetComboBoxManager().setValue(currentCstRlTypeForAdd);//TODO 注意变成常量
            //$("#cstRlTyp").ligerGetComboBoxManager().updateStyle();
        }
    }

    //刷新担保人组件
    function reloadCstRlTypDBR(_bizCd) {
        var _url = '<%=path%>/customer/cstbscinfo/toCstGuarDynamicPage.do';
        //如果有参数则在第二个参数中传入
        $("#cstGuarDynamicBizdiv").load(_url, {bizCd: _bizCd}, function (responseText, textStatus) {
            //dynamicCstRlTypBizPageUIInst();//重新设置字段样式,本方法应该在动态页面中自己根据动态字段写好
            $("#formSet1").check_ligerFormEditor();
            var form = new liger.get("formSet1");
            form.setData({
                guarTypCd: tempGuarTypCd,
                guarAmt: tempGuarAmt
            });
            if (liger.get("guarTypCd")) {//担保方式-禁用
	            liger.get("guarTypCd").setDisabled(true);
	        }
	        if (liger.get("guarAmt")) {//最高保证金额(元)-禁用
	            liger.get("guarAmt").setDisabled(true);
	        }
        });

        //重新赋值使用
        _url = '<%=path%>/customer/cstbscinfo/toCstGuarDynamicPageForCorp.do';
        //如果有参数则在第二个参数中传入
        $("#cstGuar1DynamicBizdiv").load(_url, {bizCd: _bizCd}, function (responseText, textStatus) {
            $("#formSet1").check_ligerFormEditor();//重新刷新页面动态字段
            var form = new liger.get("formSet1");
            form.setData({
                mchr9: tempMchr9
            });
            if (liger.get("mchr9")) {//股东关系-禁用
	            liger.get("mchr9").setDisabled(true);
	        }
        });
    }

    //保存事件
    function saveEvent() {
        $("#saveBtn1").click(function (event) {
        	var formSet1 = liger.get("formSet1");
            if (!formSet1.valid()) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            //判断页面是否有变更
            if(isChange == 0){
            	UIUtils.alertWarning("客户信息无变更，不允许发起流程！");
                return false; 
            }
            saveBscInfo();//保存
        });
    }
    
	//发起主要信息变更流程
    function startCstModFlow() {
        var modelTyp = 'C001';//流程业务分类
        if (StringUtils.isEmpty(modelTyp)) {
            return;
        }
        var flowDialog = $.ligerDialog.SQopen({
            url: '<%=path%>/flow/flow/toForStartListPage.do?modelTyp=' + modelTyp,
            width: 700,
            height: 400,
            title: '请选择要发起的流程',
            buttons: [{
                text: "确定", type: 'ok', cls: 'l-dialog-btn-ok',
                onclick: function (item, Dialog) {
                    if (Dialog.onOk) {
                        $.ligerDialog.SQconfirm('是否确定发起变更流程?', function (flag) {
                            if (flag == false) {
                                return;
                            } else {
                                Dialog.onOk();
                            }
                        })
                    }
                }
            }, {
                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
                onclick: function (item, Dialog) {
                    if (Dialog.onCancel) Dialog.onCancel();
                }
            }
            ],
            onClose: function () {
                var json = flowDialog._DATA;
                if (!json) {
                    return;
                }
                //saveBscInfo(json);
            }
        });
    }
	
	//保存基本信息
    function saveBscInfo(json){
        var form = liger.get("formSet1");
        if (!form.valid()) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var id = $("#cId").val();
//         //中征码验证
//         var loanCardCd = $("#loanCardCd").val();
//         var loanCardCdflag = true;
//         $.ajax({
//             type: 'post',
//             async:false,
//             dataType:'json',
//             data:{loanCardCd:loanCardCd,
//             id:id},
<%--             url: '<%=path%>/customer/cstbscinfo/checkLoanCardNo.do', --%>
//             success:function(msg){
//                 if(msg.success != 1){
//                     $.ligerDialog.SQalert({content: msg.info,SQ_type: "warning"});
//                     loanCardCdflag = false;
//                 }
//             }
//         });
//         if(!loanCardCdflag){
//             return false;
//         }
        //获取企业团队信息
        getDataList();
        //alert(dataList);
        if (checkFlag == 1) {
            return;
        }
        var data = form.getData();
		//检查客户是否存在
		data["corpLowerNm"] = data.lowerCstNm;//法人代表名称
		data["corpLowerCertNo"] = data.lowerCertNo;//法人身份证
        var isExist = checkCorpIsExist(data);
        if(isExist == 1){
        	$.ligerDialog.SQalert({content: "修改后的客户信息与系统中的其他客户信息重复！",SQ_type: "error"});
        	return ;
        }
		//验证手机三要素-REQ-3424
        var cfcaFlag = checkThreeElements(data);
       	if(cfcaFlag == 0){
           	return ;
		}
        data["dataList"] = dataList;
        data["regDt"] = $("#regDt").val();
        data["expDt"] = $("#expDt").val();
//         //流程参数
//         if (StringUtils.isNotEmpty(json)) {
//             data["procDefKey"] = json.procDefKey;
//             data["procDefId"] = json.procDefId;
//             data["procNo"] = json.procNo;
//         }
        data["modFlag"] = "yes";
        data["isFlow"] = isFlow ;
        data["isModify"]= isModify;
        data["modId"]= modId;
        data["currentBuOrgCd"] = currentBuOrgCd;
        var url = '<%=path%>/customer/cstbscinfo/modifyCorp.do';
        if (id != "") {
            data["id"] = id;
        }else{
        	 $.ligerDialog.SQalert({content: "业务主键为空，无法继续操作！",SQ_type: "warning"});
        	 return false;
        }

        var docArray = JSON.stringify(getUploadResultParams());

        //赋值附件
        data["docArray"] = docArray;

        //请求
        AjaxUtils.ajaxPost(url, data, function (msg) {
            if (msg.success == 1) {
                checkFlag = 0;
                top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
                if (msg.data) {
                    $("#cId").val(msg.data);
                    refreshUlFileRecListByPkId(msg.data, "CST_BSC_INFO");
                }
                pageInApp.flag = false;
                //刷新附件页面GRID方法和清空上传按钮
                clearUploadResultParams();
                if(!modId){
					 Remove_navTab();//关闭申请窗口
				 }
            } else {
            	top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
            }
        }, true);
	}
    
    //初始化Tab页
    function initTab() {
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onBeforeSelectTabItem: function (tabid) {
                var _cId = $("#cId").val();
                if (tabid != "tabA" && tabid!="tabK") {
                    if (pageInApp.flag) {
                        $.ligerDialog.SQalert({content: LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO, SQ_type: "warning"});
                        return false;
                    }
                }
            },
            onAfterSelectTabItem: function (tabid) {
                if (loadedTabs.indexOf(tabid) < 0) {
                    //获取客户ID供其它页面使用
                    var _cId = $("#cId").val();
                    var _cstNm = $("#cstNm").val();
                    if (tabid != "tabA") {
                        if (!_cId) {
                            $.ligerDialog.SQalert({
                                content: LogUtils.LOG_CUST_CONFIRM_HERE_HAS_INFO,
                                SQ_type: "warning"
                            });
                            return false; //请确定客户信息存在后在操作！
                        }
                    }
                    loadedTabs.push(tabid);
                    switch (tabid) {
	                    case "tabB":
	                        pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toCustCstBacInfoCorpEpRecordDetailPage.do?cstId="+_cId);
	                        break;
	                    case "tabH":
	                        var parms = "?cstId="+_cId+"&cstNm="+_cstNm;
	                        pageInTab.setTabItemSrc(tabid,"<%=path%>/customer/cstbscinfo/toCstProjectDetailPage.do"+parms);
	                        break;
	                    case "tabC":
	                        pageInTab.setTabItemSrc(tabid,"<%=path%>/customer/cstbscinfo/toCustCstBacInfoEpAssetPage.do?cstId="+_cId);
	                        break;
	                    case "tabD":
	                        pageInTab.setTabItemSrc(tabid,"<%=path%>/customer/cstbscinfo/toCstCreditPage.do?cstId="+_cId);
	                        break;
	                    case "tabE":
	                        pageInTab.setTabItemSrc(tabid,"<%=path%>/customer/cstbscinfo/toFilFinanceDebtDetailPage.do?cstId="+_cId);
	                        break;
	                    case "tabF":
	                        pageInTab.setTabItemSrc(tabid,"<%=path%>/customer/cstmidmaninfo/toDetailListPage.do?cstId="+_cId);
	                        break;
	                    case "tabG":
	                        pageInTab.setTabItemSrc(tabid,"<%=path%>/customer/cstcommrec/toDetailListPage.do?cstId="+_cId);
	                        break;
	                    case "tabI":
	                        pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbank/toCustCstBacInfoCorpBankDetailListPage.do?cstId="+_cId);
	                        break;
	                    case "tabK":
	                        var parms = "?cstId=" + _cId + "&cstNm=" + _cstNm;
	                        pageInTab.setTabItemSrc(tabid, "<%=path%>/risk/rskCstSignLog/toListPage.do" + parms);
	                        break;
	                    case "tabP":
	                        var cstRlTyp = liger.get("cstRlTyp").getValue(); //客户关系：1 客户 2担保人
	                        if(cstRlTyp.search("2") != -1){ //担保人
	                            var parms = "?cstId="+_cId+"&cstNm="+_cstNm;
	                            pageInTab.setTabItemSrc(tabid,"<%=path%>/customer/cstbscinfo/toPrjCstBscDetailPage.do"+parms);
	                        }else{
	                            $.ligerDialog.SQalert({content:"该客户不是担保人，无担保项目！", SQ_type: "warning"});
	                        }
	                        break;
                        case "tabR"://变更记录
                        	pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstbscinfo/toModRecListPage.do?modId=" + modId + '&cId=' + _cId);
                            break;
                    }
                }
                ;
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    };

    //初始化表单
    function initForm() {
        ligerPersonForm = $("#formSet1").ligerForm({
            validate: true
        });
        $("#formSet1").check_ligerFormEditor();//重新刷新页面动态字段
    };

    //客户类型切换事件
    function customerTypeChangeEvent() {
        var customerType_val = $("[name=customerTYPE]:checked").val();
        $("[name=customerTYPE]").click(function (event) {
            var Rval = $(this).ligerGetRadioManager().input.val();
            if (customerType_val == Rval) return;

            $.ligerDialog.SQconfirm(LogUtils.LOG_CUST_SWAP_TAB_BASE_INFO, function (flag) {
                if (flag == false) {
                    //RADIO 重新选择回到企业
                    $("input[name='customerTYPE'][value=2]").prev(".l-radio").click();
                    return;
                }
                ;
                customerType_val = Rval;
                var tabid = "addnewCustomer";
                var url;
                switch (Rval) {
                    case "2":
                        url = "<%=path%>/customer/cstbscinfo/toCustCstBacInfoCorpAddPage.do";
                        break;
                    case "1":
                        url = "<%=path%>/customer/cstbscinfo/toCustCstBacInfoNpAddPage.do";
                        break;
                }
                if (parent.parent && parent.parent.mainApp && parent.parent.mainApp.parentTab) {
                    var navTab = parent.parent.mainApp.parentTab;
                    navTab.setTabItemSrc(tabid, url);
                }
                ;
            });
        });
    };

    //修改初始化数据
    //只为了动态表单赋值使用,动态表单的数据只有在加载完成后才可以赋值
    var tempGuarTypCd;
    var tempGuarAmt;
    var indCdVal;//所属行业
    var stdIndCd;//标准经济行业分类
    var stdIndCdInitPass = false;//判断标准行业分类是否已经初始化完成,这样可以赋值
    var tempMchr9;//担保人-股东关系
    var ligerPersonForm;

    function initData() {
        var _id = $("#cId").val();

        $("#isInst").val(0);

        if (!_id) {
            $("input[initNm='initTeamNm']").val("${lowerCstNm }");
            $("input[initNo='initTeamCertNo']").val("${lowerCertNo }");
            $("input[initNo='initTeamCertNo']").attr("disabled", "disabled");
            $("input[initNm='initTeamNm']").attr("disabled", "disabled");
            $("select[initTyp='initTyp']").attr("disabled", "disabled");
            $("select[initTyp='initTyp']").val("${corpForCertTypCd }");
            return;
        }

        $("#rows tr").each(function () {
            if ($(this).find("#mTypCd").val() == '1') {
                $(this).find("#teamNm").attr("disabled", "disabled");
                $(this).find("#teamCertNo").attr("disabled", "disabled");
                $(this).find("#tcorpForCertTypCd").attr("disabled", "disabled");
                //设置上方法人信息展示
                liger.get("formSet1").setData({
                    lowerCstNm: $(this).find("#teamNm").val(),
                    corpForCertTypCd: $(this).find("#tcorpForCertTypCd").val(),
                    lowerCertNo: $(this).find("#teamCertNo").val()
                });
            }
            //绑定change事件
            $(this).on("change",changeEvent);
        });

        var _url = '<%=path%>/customer/cstbscinfo/getById.do';
		//判断是否有变更主表ID-是否流程中
    	if(modId){
            _url = '<%=path%>/customer/cstbscinfo/getCstInfoFlowById.do';
		}
        AjaxUtils.ajaxGet(_url, {id: _id, modId:modId, currentBuOrgCd:currentBuOrgCd}, function (msg) {
            if (msg.success == 1) {
                setData(msg.data);//设置数据
                tempData = msg.data;
                pageInApp.flag = false;
                if (!msg.data.certTypCd == "c") {
                    disableBeforeItem();//禁用证件号
                }
                disableCustomerTYPE();
            } else {
                UIUtils.alertError(msg.info);
            }
        }, false);
    }

    //设置页面数据
    function setData(data) {
        var form = new liger.get("formSet1");
        form.setData({
            cstLvlCd: data.cstLvlCd,
            corpTypCd: data.cstCorpBscInfoVO.corpTypCd,
            regCapUntCd: data.cstCorpBscInfoVO.regCapUntCd,
            paidCapUntCd: data.cstCorpBscInfoVO.paidCapUntCd,
            othIndCd: data.othIndCd,
            cstNm: data.cstNm,
            payTypCd: data.payTypCd,
            taxRegNo: data.cstCorpBscInfoVO.taxRegNo,
            bizLicNo: data.cstCorpBscInfoVO.bizLicNo,
            regCapAmt: data.cstCorpBscInfoVO.regCapAmt,
            oldRegCapAmt: data.cstCorpBscInfoVO.regCapAmt,
            paidCapAmt: data.cstCorpBscInfoVO.paidCapAmt,
            bizScope: data.cstCorpBscInfoVO.bizScope,
            regAddr: data.cstCorpBscInfoVO.regAddr,
            postAddr: data.cstCorpBscInfoVO.postAddr,
            cstRem: data.cstRem,
            certNo: data.certNo,
            certTypCd: data.certTypCd,
            mp: data.mp,
            shtNm: data.cstCorpBscInfoVO.shtNm,
            //succ:data.cstCorpBscInfoVO.succ,
            corpTax: data.cstCorpBscInfoVO.corpTax,
            regTel: data.cstCorpBscInfoVO.regTel,
            officeTel: data.cstCorpBscInfoVO.officeTel,
            officeArea: data.cstCorpBscInfoVO.officeArea,
            prpAttr: data.cstCorpBscInfoVO.prpAttr,
            loanCardNo: data.cstCorpBscInfoVO.loanCardNo,
            loanCardPwd: data.cstCorpBscInfoVO.loanCardPwd,
            loanCardCd: data.cstCorpBscInfoVO.loanCardCd,
            loanAss: data.cstCorpBscInfoVO.loanAss,
            guarTypCd: data.cstCorpBscInfoVO.guarTypCd,
            guarAmt: data.cstCorpBscInfoVO.guarAmt,
            isInst: data.cstCorpBscInfoVO.isInst,
            perMitNo: data.cstCorpBscInfoVO.perMitNo,
            regStdProvCd: data.cstCorpBscInfoVO.regProvCd,
            regStdCityCd: data.cstCorpBscInfoVO.regCityCd,
            regStdDistCd: data.cstCorpBscInfoVO.regDistCd,
            loanCardCd: data.cstCorpBscInfoVO.loanCardCd,
            prpVal: data.cstCorpBscInfoVO.prpVal
        });

        //设置回显标准省市县
        setSysStdProvCdUpdateValue(data.cstCorpBscInfoVO.regProvCd);//省
        setSysStdCityCdUpdateValue(data.cstCorpBscInfoVO.regCityCd);//市
        setSysStdDistCdUpdateValue(data.cstCorpBscInfoVO.regDistCd);//县
        //设置完回显值执行省市县变更事件
        setSysStdProvCdChange();
        setSysStdCityCdChange();

        stdIndCd = data.cstCorpBscInfoVO.stdIndCd;
        indCdVal = data.indCd;
        if (indCdVal) {
            var indCdTreeSelect = liger.get("indCd");
            if (indCdTreeSelect) {
                indCdTreeSelect.setValue(indCdVal);
            }
        }

        if (stdIndCd) {
            var stdIndCdTreeSelect = liger.get("stdIndCd");
            if (stdIndCdTreeSelect && stdIndCdInitPass == true) {
                stdIndCdTreeSelect.setValue(stdIndCd);
            }
        }

        if (data.cstCorpBscInfoVO.regDt) {
            var date = new Date(data.cstCorpBscInfoVO.regDt);
            var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
            $("#regDt").val(dateStr);
        }
        if (data.cstCorpBscInfoVO.expDt) {
            var date = new Date(data.cstCorpBscInfoVO.expDt);
            var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
            $("#expDt").val(dateStr);
        }
        if (data.cstCorpBscInfoVO.corpRepBd) {
            var date = new Date(data.cstCorpBscInfoVO.corpRepBd);
            var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
            $("#corpRepBd").val(dateStr);
        }

        $("#cstRlTyp").ligerGetComboBoxManager().setValue(data.cstRlAttr);
        //set customer rlattr
        if (data.cstRlAttrVOList) {
            form.setData({
                prjCtrlCd: data.prjCtrlCd
            });
        }
        //设置法定代表人名称和身份证号码
        if (data.cstCorpBscInfoVO.cstCorpTeamVO) {
            form.setData({
                //lowerCstNm: data.cstCorpBscInfoVO.cstCorpTeamVO.mnm,
                //corpForCertTypCd: data.cstCorpBscInfoVO.cstCorpTeamVO.certTypCd,
                //lowerCertNo: data.cstCorpBscInfoVO.cstCorpTeamVO.certNo
            });
        }

        //辅助信息
        if (data.cstExtInfoVO) {
            tempGuarTypCd = data.cstExtInfoVO.schr6;
            tempGuarAmt = data.cstExtInfoVO.num9;
            tempGuarAmt = NumberUtils.isScientificNotationToString(tempGuarAmt);
            tempMchr9 = data.cstExtInfoVO.mchr9;
            form.setData({
                ext_schr1: data.cstExtInfoVO.schr1,
                ext_schr2: data.cstExtInfoVO.schr2,
                ext_schr3: data.cstExtInfoVO.schr3,
                ext_schr4: data.cstExtInfoVO.schr4,
                ext_schr5: data.cstExtInfoVO.schr5,
                ext_schr6: data.cstExtInfoVO.schr6,
                ext_mchr1: data.cstExtInfoVO.mchr1,
                ext_mchr2: data.cstExtInfoVO.mchr2,
                ext_mchr3: data.cstExtInfoVO.mchr3,
                ext_mchr4: data.cstExtInfoVO.mchr4,
                ext_mchr5: data.cstExtInfoVO.mchr5,
                ext_mchr6: data.cstExtInfoVO.mchr6,
                ext_mchr7: data.cstExtInfoVO.mchr7,
                ext_mchr8: data.cstExtInfoVO.mchr8,
                mchr9: data.cstExtInfoVO.mchr9,
                ext_bchr1: data.cstExtInfoVO.bchr1,
                ext_bchr2: data.cstExtInfoVO.bchr2,
                ext_num1: data.cstExtInfoVO.num1,
                ext_num2: data.cstExtInfoVO.num2,
                ext_num3: data.cstExtInfoVO.num3,
                ext_num4: data.cstExtInfoVO.num4,
                ext_num5: data.cstExtInfoVO.num5,
                ext_num6: data.cstExtInfoVO.num6,
                ext_num7: data.cstExtInfoVO.num7,
                ext_num8: data.cstExtInfoVO.num8,
                ext_num9: data.cstExtInfoVO.num9
            });
        }
        if (data.certTypCd == "c") {
            liger.get("certTypCd").setEnabled(true);
            liger.get("certNo").setEnabled(true);
            $("#certNo").val("");
        }

    };

    //身份证件录入后需要调用后台查看用户信息是否存在,存在则提示是否要获取
    function certNoKeyUpEvent() {
        $("#certNo").change(function (event) {//如果身份证已经输入完成(15或18位)后, 如果用户名称存在则则后台判断是否存在
            var val = $(this).val();
            checkExistInfo();
        });
    };

    //检查是否存在客户信息
    function checkExistInfo() {
        var wait_dialog = $.ligerDialog.SQalert({
            content: LogUtils.LOG_CMM_LOADING,
            SQ_type: "waitting",
            onClose: function () {
            }
        });

        var _certNo = $("#certNo").val();
        var _url = '<%=path%>/customer/cstbscinfo/getExistCorp.do';
        $.ajax({
            type: 'get',
            dataType: 'json',
            data: {certNo: _certNo},
            url: _url,
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    $.ligerDialog.SQconfirm(LogUtils.LOG_CUST_INFO_EXIST, function (flag) {
                        $("#cId").val(msg.data.cId);//设置数据
                        if (flag == true) {
                            initData();
                        }//不带入信息则需要锁定用户名和密码,因为数据已经存在已经不需要在验证身份证信息了
                        pageInApp.flag = false;//tab页验证关闭
                        //设置客户名称
                        $("#cstNm").val(msg.data.cstNm);
                        //禁用用户名和身份证号码
                        disableVIDInfo();
                        enableAfterItem();
                    });
                } else {
                    $("#cId").val("");
                    enableAfterItem();
                    //$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });
    };

    //禁用客户类型选项
    function disableCustomerTYPE() {
        if ($("[name=customerTYPE]")) {//特殊情况使用
            var obj = $("[name=customerTYPE]");
            obj.setDisabled_ligerRadio(true);
        }
        ;
    }

    //禁用主要信息
    function disableVIDInfo() {
        liger.get("certNo").setDisabled(true);
    }

    //新增禁用字段
    function disableBeforeItem() {
        //如果是修改操作则不做操作
        var cId = $("#cId").val();
        if (cId) {//不为空
            liger.get("certNo").setDisabled(true);
            return;
        }
        changeItemStatus(true);
    };

    //新增启用字段
    function enableAfterItem() {
        changeItemStatus(false);
    };


    //通过true(禁用) false(启用)
    function changeItemStatus(tf) {
        if (liger.get("cstLvlCd")) {//客户分级
            var obj = liger.get("cstLvlCd");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("cstRlTyp")) {//客户关系
            var obj = liger.get("cstRlTyp");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("corpTypCd")) {//企业性质
            var obj = liger.get("corpTypCd");
            tf == true ? obj.setDisabled() : obj.setEnabled();
        }
        if (liger.get("regCapUntCd")) {//注册资本金-单位
            var obj = liger.get("regCapUntCd");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("paidCapUntCd")) {//实收资本金-单位
            var obj = liger.get("paidCapUntCd");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("indCd")) {//所属行业
            var obj = liger.get("indCd");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("regCapAmt")) {//注册资本金
            var obj = liger.get("regCapAmt");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("paidCapAmt")) {//实收资本金
            var obj = liger.get("paidCapAmt");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("bizScope")) {//经营范围
            var obj = liger.get("bizScope");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("prpAttr")) {//房产属性
            var obj = liger.get("prpAttr");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("regAddr")) {//注册地址
            var obj = liger.get("regAddr");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("postAddr")) {//通讯地址
            var obj = liger.get("postAddr");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("prjCtrlCd")) {//立项控制
            var obj = liger.get("prjCtrlCd");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if ($("#loanAss")) {//贷款事项约定
            var obj = $("#loanAss");
            tf == true ? obj.setDisabled_ligerTextarea(tf) : obj.setDisabled_ligerTextarea(tf);
        }
        if ($("#cstRem")) {//备注
            var obj = $("#cstRem");
            tf == true ? obj.setDisabled_ligerTextarea(tf) : obj.setDisabled_ligerTextarea(tf);
        }
        if (liger.get("isInst")) {//是否事业单位
            var obj = liger.get("isInst");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("perMitNo")) {//开户许可证核准号
            var obj = liger.get("perMitNo");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("shtNm")) {//企业简称
            var obj = liger.get("shtNm");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("corpTax")) {//企业传真
            var obj = liger.get("corpTax");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("regTel")) {//注册电话
            var obj = liger.get("regTel");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("officeTel")) {//办公电话
            var obj = liger.get("officeTel");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("officeArea")) {//办公用房使用权面积
            var obj = liger.get("officeArea");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("payTypCd")) {//还款方式
            var obj = liger.get("payTypCd");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("regDt")) {//成立日期
            var obj = liger.get("regDt");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("expDt")) {//营业期限至
            var obj = liger.get("expDt");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("stdIndCd")) {//经济行业分类
            var obj = liger.get("stdIndCd");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("prpVal")) {//房产价值
            var obj = liger.get("prpVal");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        //注册地行政区划
        if (liger.get("regStdProvCd")) {//省份
            var obj = liger.get("regStdProvCd");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("regStdCityCd")) {//城市
            var obj = liger.get("regStdCityCd");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        if (liger.get("regStdDistCd")) {//区\县
            var obj = liger.get("regStdDistCd");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }

        //附加信息
        if (liger.get("ext_schr1")) {
            var obj = liger.get("ext_schr1");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_schr2")) {
            var obj = liger.get("ext_schr2");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_schr3")) {
            var obj = liger.get("ext_schr3");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_schr4")) {
            var obj = liger.get("ext_schr4");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_schr5")) {
            var obj = liger.get("ext_schr5");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_mchr1")) {
            var obj = liger.get("ext_mchr1");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_mchr2")) {
            var obj = liger.get("ext_mchr2");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_mchr3")) {
            var obj = liger.get("ext_mchr3");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_mchr4")) {
            var obj = liger.get("ext_mchr4");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_mchr5")) {
            var obj = liger.get("ext_mchr5");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_mchr6")) {
            var obj = liger.get("ext_mchr6");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_mchr7")) {
            var obj = liger.get("ext_mchr7");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_mchr8")) {
            var obj = liger.get("ext_mchr8");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_bchr1")) {
            var obj = liger.get("ext_bchr1");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_bchr2")) {
            var obj = liger.get("ext_bchr2");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_bchr3")) {
            var obj = liger.get("ext_bchr3");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num1")) {
            var obj = liger.get("ext_num1");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num2")) {
            var obj = liger.get("ext_num2");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num3")) {
            var obj = liger.get("ext_num3");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num4")) {
            var obj = liger.get("ext_num4");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num5")) {
            var obj = liger.get("ext_num5");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num6")) {
            var obj = liger.get("ext_num6");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num7")) {
            var obj = liger.get("ext_num7");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num8")) {
            var obj = liger.get("ext_num8");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num9")) {
            var obj = liger.get("ext_num9");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num10")) {
            var obj = liger.get("ext_num10");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num11")) {
            var obj = liger.get("ext_num11");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num12")) {
            var obj = liger.get("ext_num12");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num13")) {
            var obj = liger.get("ext_num13");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num14")) {
            var obj = liger.get("ext_num14");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
        if (liger.get("ext_num15")) {
            var obj = liger.get("ext_num15");
            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
        }
        ;
    }

    //设置禁用字段
    function disabledField() {
        liger.get("certTypCd").setDisabled(true);
        liger.get("corpForCertTypCd").setDisabled(true);
    }

    //身份证第三方验证事件
    function npVerifyIDEvent(verify) {
        $.ajax({
            type: 'post',
            async: false,
            dataType: 'json',
            data: {verify: verify},
            url: '<%=path%>/customer/cstbscinfo/validateIdCards.do',
            success: function (msg) {
                if (msg.success == 1) {
                    checkFlag = 0;
                } else {//验证未通过
                    UIUtils.alertWarning(msg.info);
                    checkFlag = 1;
                }
            }
        });
    };

    $("#cst_corp_team_add_btn_id").click(function (event) {
        $("#rows").append('<tr><td class="td"><div><select name="mTypCd" id="mTypCd"> <c:forEach items="${searchSelectMTypCdList }" var="kv" begin="0" step="1" varStatus="status"><c:if test="${kv.key != 1}"><option value="${kv.key }">${kv.value }</option></c:if></c:forEach></select></div></td><td class="td"><div><input name="teamNm" id="teamNm" type="text" value=""></div></td><td class="td"><div><select name="tcorpForCertTypCd" id="tcorpForCertTypCd"><c:forEach items="${searchSelectCertTypCdForNpList }" var="kv" begin="0" step="1" varStatus="status"><c:if test="${status.index == 0}"><option value="${kv.key }" checked >${kv.value }</option></c:if><c:if test="${status.index != 0}"><option value="${kv.key }">${kv.value }</option></c:if></c:forEach></select></div></td><td class="td"><div><input name="teamCertNo" id="teamCertNo" type="text" value="" ></div></td><td class="td"><div><input name="teamMp1" id="teamMp1" type="text" value="" ></div></td><td class="td"><div><a class="sq-button-hasicon" style="cursor:pointer" onclick="deleteRow(this)"><i class="sqBtnIco_7"></i>删除</a></div></td></tr>');
        changeEvent(); //新增团队成员-触发变更状态方法
    });

    function deleteRow(owner) {
        var ctId = $(owner).parent().parent().parent().find("#teamId").val();
        if (ctId != undefined) {
            $.ligerDialog.SQconfirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
                if (flag == false) return;
                var _url = '<%=path%>/customer/cstcorpteam/removeById.do';
                AjaxUtils.ajaxPost(_url, {id: ctId}, function (msg) {
                    if (msg.success == 1) {
                        $(owner).parent().parent().parent().remove();
                        UIUtils.alertSuccess(msg.info);
                    } else {
                        UIUtils.alertError(msg.info);
                    }
                }, true);
            });
        } else {
            $(owner).parent().parent().parent().remove();
        }
    }

    function getDataList() {
        dataList = "";
        var verify = "";
        $("#rows tr").each(function () {
            verify += $(this).find("#teamNm").val() + ".,";
            verify += $(this).find("#teamCertNo").val() + ".,";
            verify += $(this).find("#tcorpForCertTypCd").val() + ".@";
            if (($(this).find("#teamId").val()) != undefined) {
                dataList += $(this).find("#teamId").val() + ".,";
            } else {
                dataList += ".,";
            }
            dataList += $(this).find("#mTypCd").val() + ".,";
            dataList += $(this).find("#teamNm").val() + ".,";
            dataList += $(this).find("#teamCertNo").val() + ".,";
            dataList += $(this).find("#teamMp1").val() + ".,";
            dataList += $(this).find("#tcorpForCertTypCd").val() + ".@";
        });
        npVerifyIDEvent(verify);
    }
    //校验统一社会信用编码
    function CheckSocialCreditCodeOrg(Code) {
        var patrn = /^[0-9A-Z]+$/;
        //18位校验及大写校验
        if ((Code.length != 18) || (patrn.test(Code) == false))
        {
            return false;
        }
        else
        {
            var Ancode;//信用代码/税号的每一个值
            var Ancodevalue;//信用代码/税号每一个值的权重
            var total = 0;
            var weightedfactors = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28];//加权因子
            var str = '0123456789ABCDEFGHJKLMNPQRTUWXY';
            //不用I、O、S、V、Z
            for (var i = 0; i < Code.length - 1; i++)
            {
                Ancode = Code.substring(i, i + 1);
                Ancodevalue = str.indexOf(Ancode);
                total = total + Ancodevalue * weightedfactors[i];
                //权重与加权因子相乘之和
            }
            var logiccheckcode = 31 - total % 31;
            if (logiccheckcode == 31)
            {
                logiccheckcode = 0;
            }
            var Str = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,T,U,W,X,Y";
            var Array_Str = Str.split(',');
            logiccheckcode = Array_Str[logiccheckcode];


            var checkcode = Code.substring(17, 18);
            if (logiccheckcode != checkcode)
            {
                return false;
                // alert("不是有效的统一社会信用编码！");
            }else{
                return true;
            }
        }
    }

    //税人识别号验证 (1)
    function checkTaxpayerId(taxpayerId){
        if(taxpayerId!="" && taxpayerId.length===15){
            var addressCode = taxpayerId.substring(0,6);
            // 校验地址码
            var check = checkAddressCode(addressCode);
            if(!check){
                return false;
            }
            // 校验组织机构代码
            var orgCode = taxpayerId.substring(6,9);
            check = isValidOrgCode(orgCode);
            if(!check){
                return false;
            }
            return true;
        }else{
            return false;
        }
    }
    //税人识别号验证 (2)
    function isValidOrgCode(value){
        if(value!=""){
            var part1=value.substring(0,8);
            var part2=value.substring(value.length-1,1);
            var ws = [3, 7, 9, 10, 5, 8, 4, 2];
            var str = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
            var reg = /^([0-9A-Z]){8}$/;
            if (!reg.test(part1))
            {
                return true
            }
            var sum = 0;
            for (var i = 0; i< 8; i++)
            {
                sum += str.indexOf(part1.charAt(i)) * ws[i];
            }
            var C9 = 11 - (sum % 11);
            var YC9=part2+'';
            if (C9 == 11) {
                C9 = '0';
            } else if (C9 == 10) {
                C9 = 'X' ;
            } else {
                C9 = C9+'';
            }
            return YC9!=C9;
        }
    }

    //税人识别号验证 (3)
    function checkAddressCode(addressCode){
        var provinceAndCitys={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",
            31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",
            45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",
            65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"};
        var check = /^[1-9]\d{5}$/.test(addressCode);
        if(!check) return false;
        if(provinceAndCitys[parseInt(addressCode.substring(0,2))]){
            return true;
        }else{
            return false;
        }

    }
    
    //设置表单域是否可修改状态：通过true(禁用) false(启用)
    function changeModStatus(tf) {
    	//判断客户状态（13：已立项  14：有担保项目） 
    	if(_audStsCd == "13" || _audStsCd == "14"){//只能修改法人手机号
    		if (liger.get("cstNm")) {//企业名称-禁用
	            liger.get("cstNm").setDisabled(true);
	        }
	        if (liger.get("certNo")) {//证件号码-禁用
	            liger.get("certNo").setDisabled(true);
	        }
	        if (liger.get("bizLicNo")) {//营业执照注册号-禁用
	            liger.get("bizLicNo").setDisabled(true);
	        }
	        if (liger.get("taxRegNo")) {//税务登记证-禁用
	            liger.get("taxRegNo").setDisabled(true);
	        }
	        if (liger.get("lowerCstNm")) {//法定代表人-禁用
	            liger.get("lowerCstNm").setDisabled(true);
	        }
	        if (liger.get("lowerCertNo")) {//代表人身份证号码-禁用
	            liger.get("lowerCertNo").setDisabled(true);
	        }
	        //设置团队信息不可编辑
	        $("#rows tr").each(function () {
	            if ($(this).find("#mTypCd").val() != '1') {
	            	$(this).find("#mTypCd").attr("disabled",true); //职务
	                $(this).find("#teamNm").attr("disabled",true); //姓名
	                $(this).find("#tcorpForCertTypCd").attr("disabled",true); //证件类型
	                $(this).find("#teamCertNo").attr("disabled",true); //证件号
	                $(this).find("#teamMp1").attr("disabled",true); //电话
	            }
	        });
    	}else{
	        if (liger.get("cstNm")) {//企业名称
	            var obj = liger.get("cstNm");
	            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
	        }
	        if (liger.get("certNo")) {//证件号码
	            var obj = liger.get("certNo");
	            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
	        }
	        if (liger.get("bizLicNo")) {//营业执照注册号
	            var obj = liger.get("bizLicNo");
	            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
	        }
	        if (liger.get("taxRegNo")) {//税务登记证
	            var obj = liger.get("taxRegNo");
	            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
	        }
	        if (liger.get("lowerCstNm")) {//法定代表人
	            var obj = liger.get("lowerCstNm");
	            tf == true ? obj.setDisabled() : obj.setEnabled();
	        }
	        if (liger.get("lowerCertNo")) {//代表人身份证号码
	            var obj = liger.get("lowerCertNo");
	            tf == true ? obj.setDisabled(tf) : obj.setEnabled();
	        }
    	}
    }
    
	//身份证第三方验证事件-法人
    function frVerifyID(){
    	//$(".addFrVerifyID").on('click', function(event) {
			//显示图片验证-法人
			if($("#corpForCertTypCd").val()==0){
				$("#sFrVerifyID").show();
			}else{
				$("#sFrVerifyID").hide();
			}
    		//判断是否已验证
   			if($("#addFrVerifyID").attr("pass") == 'y'){
       			return;
       		}
    		
    		//上面是判断是否完成验证,如果完成了就停止,下面继续
    		var form = new liger.get("formSet1");
    		if (!form.valid()) {
				$.ligerDialog.SQalert({content: "请填写正确信息！",SQ_type: "warning"});
				return false; //验证不通过，不执行以下代码
			}
            var wait_dialog = UIUtils.alertWaiting(LogUtils.LOG_CMM_DATA_LOADING);
            var data = form.getData();
            //alert(JSON.stringify(data));
            var cstNm = data.lowerCstNm;//法定代表人姓名
            var certNo = data.lowerCertNo;//证件号码
            var validNmTip = LogUtils.LOG_CUST_NAME_NOT_EMPTY;
            var validNoTip = LogUtils.LOG_CUST_ID_CARD_NOT_EMPTY;
            
            if(!cstNm){
            	wait_dialog.close();
            	UIUtils.alertWarning(validNmTip);
                return; //验证不通过，不执行以下代码
            }
            if(!certNo){
            	wait_dialog.close();
            	UIUtils.alertWarning(validNoTip);
                return; //验证不通过，不执行以下代码
            }
            
            _mySelfIDImgUrl = "";//每次验证都要赋空值在赋新值
            
            $.ajax({
           		type: 'post',
           		dataType:'json',
           		data:{cstNm:cstNm,certNo:certNo},
           		url: '<%=path%>/customer/cstbscinfo/validateIdCard.do',
           		success:function(msg){
           			 wait_dialog.close();
           			 if(msg.success == 1){
           				if(msg.data){
           					if(msg.data.absolutePath){
           						//把这个地址记录上,后面要随保存数据一起存储
           						_mySelfIDImgUrl = msg.data.absolutePath;
           					}
           				}
           				//说明已经三方验证通过
           				UIUtils.alertSuccess(msg.info);
                        disableVIDInfo(); //验证通过后直接禁用输入框
                        setFrTeamInfo(); //设置法人信息
                        $("#sFrVerifyID").html(getVerfiedIDHtmlPass());
                        $(".liger_tip").ligerTip(); // HTML元素更新后，重新ligerTip实例化
           			 }else{//验证未通过
                         UIUtils.alertWarning(msg.info);
           			 }
           		}
            });
            
		//});
    }
    
	//证件号变更-设置验证初始值为不通过-重新验证
	function setFrPassNo(){//法人
		//$("#addFrVerifyID").attr("pass","n");
		$("#sFrVerifyID").html(getVerfiedIDHtmlNopass());
		//添加身份证号前台校验
		var formSet1=liger.get("formSet1");
		formSet1.setFieldValidate("lowerCertNo", {required:true, idcardno: true});
	}
	
	//验证身份通过-法人
    function getVerfiedIDHtmlPass(){
    	var html="<span class='liger_tip' id='addFrVerifyID' pass='y' title='"+LogUtils.LOG_CMM_VALID_PASS+"'><i class='sqIco sqIco_1'></i></span>";
    	return html;
    }
	
	//验证身份证未通过-法人
    function getVerfiedIDHtmlNopass(){
    	var html="<a href='javascript:;' id='addFrVerifyID' pass='n' class='liger_tip' title='"+LogUtils.LOG_CMM_VALID_FAIL+"'><i class='sqIco sqIco_2'></i></a>";
    	return html;
    }
	
	//将法人代表信息设置到[主要团队成员]列表里
	function setFrTeamInfo(){
		var lowerCstNm = $("#lowerCstNm").val();
		var lowerCertNo = $("#lowerCertNo").val();
        //遍历-设置
        $("#rows tr").each(function () {
            if ($(this).find("#mTypCd").val() == '1') {
                $(this).find("#teamNm").val(lowerCstNm);
                $(this).find("#teamCertNo").val(lowerCertNo);
            }
        });
	}
	
	//检查是否存在客户信息-法人
	function checkCorpIsExist(_data){
		var isExist = 0;
		var cId = $("#cId").val();
		var _url = '<%=path%>/customer/cstbscinfo/getExistCorp.do';
		$.ajax({
    		type:'get',
    		dataType:'json',
    		async:false,
    		url:_url,
    		data:_data,
    		success:function(msg){
    			if(msg.success == 1){//存在
    				//返回的客户ID
    				var _id = msg.data.cId;
    				if(cId != _id){
    					isExist = 1;
    				}
				}else if(msg.success == 3){//不存在
					isExist = 0;
				}else if(msg.success == 2){
					UIUtils.alertError(msg.info);
				}
    		},
    		error:function(msg){
    			UIUtils.alertError(msg.info);
    		}
    	});
		return isExist;
	}
	
	//判断页面是否有变更
	var isChange = 0;
	var arrays = ["cstNm","certNo","bizLicNo","taxRegNo","lowerCstNm","lowerCertNo"];
	for(var i=0;i<arrays.length;i++){
		$("#"+arrays[i]).on("change",changeEvent);
	}
	
	//处理变更事件
	function changeEvent(){
		isChange = 1;
	}
	
	//验证手机三要素真实性-REQ-3424
	function checkThreeElements(data){
		var cfcaFlag = 0;
		var userName = data.lowerCstNm; //用户名
		var identificationNo = data.lowerCertNo; //用户证件号
		var mobilePhone = ""; //手机号
        //获取法人手机号
        $("#rows tr").each(function () {
            if ($(this).find("#mTypCd").val() == '1') {
            	mobilePhone = $(this).find("#teamMp1").val();
            }
        });
		//手机号为空-不验证
		if(!mobilePhone){
			cfcaFlag = 1;
		}else{
			var params = {userName:userName, identificationNo:identificationNo, mobilePhone:mobilePhone};
			var _url = '<%=path%>/customer/cstbscinfo/checkThreeElements.do';
			$.ajax({
	    		type:'get',
	    		dataType:'json',
	    		async:false,
	    		url:_url,
	    		data:params,
	    		success:function(msg){
	    			if(msg.success == 1){//验证通过
						cfcaFlag = 1;
					}else if(msg.success == 0){//验证不通过
						cfcaFlag = 0;
						UIUtils.alertWarning("法人手机三要素：" + msg.info);
					}
	    		},
	    		error:function(msg){
	    			UIUtils.alertError(msg.info);
	    		}
	    	});
		}
		return cfcaFlag;
	}
</script>
</body>
</html>